Admit dynamic optional identifier calls to bytecode - #3046
Merged
rogeralsing merged 1 commit intoJun 2, 2026
Conversation
rogeralsing
deleted the
codex/unified-bytecode-loop-86-dynamic-optional-call
branch
June 2, 2026 02:42
There was a problem hiding this comment.
Pull request overview
This PR extends the unified bytecode production pipeline to admit callee-optional identifier calls (fn?.(args)) when the identifier must be resolved via the dynamic environment (e.g., captured/dynamic identifier), including eligibility checks, compiler emission, VM execution/short-circuiting, and activation-environment requirements.
Changes:
- Add and wire a new opcode
PrepareDynamicIdentifierOptionalCallTargetacross the unified bytecode compiler, eligibility analysis, VM interpreter, and activation requirements. - Expand eligibility logic to accept optional identifier call targets via dynamic identifier operations (when allowed), while continuing to decline complex argument shapes.
- Add tests for fast-path usage and nullish short-circuit behavior; update the unified-bytecode expansion contract documentation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Asynkron.JsEngine.Tests/UnifiedBytecodeProductionInvocationTests.cs | Adds invocation-level tests asserting fast-path usage and correct undefined short-circuiting for captured optional identifier calls. |
| tests/Asynkron.JsEngine.Tests/UnifiedBytecodeProductionEligibilityTests.cs | Adds eligibility tests verifying acceptance/decline behavior and opcode emission for dynamic optional identifier call targets. |
| src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeVirtualMachine.cs | Implements VM execution for PrepareDynamicIdentifierOptionalCallTarget, including nullish short-circuit jump behavior. |
| src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeProgram.cs | Introduces the new opcode in UnifiedBytecodeOpCode. |
| src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeProductionEligibility.cs | Updates first-boundary optional identifier call detection to account for admitted dynamic identifiers. |
| src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeCompiler.cs | Emits PrepareDynamicIdentifierOptionalCallTarget with packed operand (name index + jump target) when dynamic identifiers are allowed. |
| src/Asynkron.JsEngine/Ast/TypedAstEvaluator.SyncFunctionInvoker.cs | Ensures unified bytecode invocation requests an environment when the new dynamic optional opcode is present. |
| docs/unified-bytecode-expansion-contract.md | Documents the new opcode and the admitted optional identifier call shape. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
646
to
648
| The optional preparation opcodes pack a call-target constant index (low 16 | ||
| bits) and a nullish short-circuit jump target (high 16 bits) into a single | ||
| operand. The VM checks the receiver or callee for nullish before argument |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
UnifiedBytecodeProductionInvocationTests&FullyQualifiedNameCapturedOptionalIdentifierCallExpression"UnifiedBytecodeProductionEligibilityTests&FullyQualifiedNameDynamicOptionalIdentifierCallTarget"ExpressionProgramCoverageMapTests&FullyQualifiedNameUnifiedBytecodeExpansionContract_ListsRequiredHeadingsAndCurrentEnums"